import 'package:flutter/material.dart';

extension WidgetExt on Widget {
  Widget sizedBox({
    double? width,
    double? height,
  }) =>
      SizedBox(
        width: width,
        height: height,
        child: this,
      );

  Widget center({
    double? widthFactor,
    double? heightFactor,
  }) =>
      Center(
        widthFactor: widthFactor,
        heightFactor: heightFactor,
        child: this,
      );

  Widget expanded({
    int flex = 1,
  }) =>
      Expanded(
        flex: flex,
        child: this,
      );

  Widget card({
    BoxDecoration? decoration,
    EdgeInsets? padding,
    EdgeInsets? margin,
    double? width,
    double? height,
    double? radius,
    BoxBorder? border,
    BoxConstraints? constraints,
    Color? color = Colors.white,
    Clip clipBehavior = Clip.none,
    AlignmentGeometry? alignment
  }) {
    return Container(
      decoration: decoration ??
          BoxDecoration(
            borderRadius: BorderRadius.circular(radius ?? 20),
            border: border,
            color: color,
          ),
      constraints: constraints,
      clipBehavior: clipBehavior,
      alignment: alignment,
      padding: padding,
      margin: margin,
      width: width,
      height: height,
      child: this,
    );
  }

  Widget gesture(
          {required GestureTapCallback? onTap, HitTestBehavior? behavior}) =>
      GestureDetector(
        onTap: onTap,
        behavior: behavior,
        child: this,
      );
}
